package com.mybindview.util;

import android.databinding.BindingAdapter;
import android.databinding.BindingConversion;
import android.widget.TextView;

import com.mybindview.R;

/**
 * Created by nbzl on 2017/2/27.
 */
public class ViewUtil {

    @BindingAdapter({"addtext","addtag","txtcolor"})
    public static void loadTxt(TextView view, String url,String tag,int color){
        view.setText(url+"ok");
        view.setTag(""+tag);
        view.setTextColor(color);
        //view.setTextColor(txtcolor);
    }

    @BindingConversion
    public static int convertIntToString(int num) {
        switch (num) {
            case 1:
                return R.string.first_name;
            case 2:
                return R.string.second_name;
        }
        return R.string.app_name;
    }

    @BindingConversion
    public static int convertBooleanToString(boolean b) {
        if(b){
            return R.string.first_name;
        }else{
            return R.string.second_name;
        }
    }
}
